package moodish.client;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;


public class UserTest {

	private User user;
	private String nome;
	private Mood mood;
	private User friend;
	
	@Before
	public void startUser() {
		mood = Mood.Good;
		nome = "Carlos";
		user = new User(nome,mood);
		friend = new User("Manuel",Mood.Accepted);
	}
	
	/**
	 * Test to verify if a User was successfully created.	  
	 */
	@Test
	public void testUser() {
		
		assertNotNull(user);
	}

	/**
	 * Test to verify set of new Mood. 
	 */
	@Test
	public void testSetMood() {
		
		Mood newMood = Mood.Challenged;
		
		user.setMood(newMood);
		
		assertEquals(newMood, user.getMood());
	}

	
	/**
	 * Test to verify get of a Nickname.
	 */
	@Test
	public void testGetNickname() {
		
		assertEquals(nome, user.getNickname());
	}

	/**
	 * Test to verify get ImageIcon.
	 */
	@Test
	public void testGetImageIcon() {

		assertNotNull(user.getImageIcon());
	}

	/**
	 * Test to verify get Mood.
	 */
	@Test
	public void testGetMood() {
		
		assertEquals(mood, user.getMood());
	}

	/**
	 * Test to verify compareMood different.
	 */
	@Test
	public void testCompareTo() {
		
		assertNotSame(0, user.compareTo(friend));
		
	}
	
	/**
	 * Test to verify compareMood same.
	 */
	@Test
	public void testCompareToSameMood() {
		
		user.setMood(friend.getMood());
		
		assertSame(0, user.compareTo(friend));
	}

	/**
	 * Test to verify addFriend.
	 */
	@Test
	public void testAddFriend() {
		
		user.addFriend(friend);
		
		assertFalse(user.getFriends().isEmpty());
		
	}

	/**
	 * Test to verify removeFriend.
	 */
	@Test
	public void testRemoveFriend() {
		
		user.removeFriend(friend);
		
		assertTrue(user.getFriends().isEmpty());
		
	}

	/**
	 * Test to verify getFriends.
	 */
	@Test
	public void testGetFriends() {
		
		assertNotNull(user.getFriends());
	}

	/**
	 * Test to verify removing all friends from a User.
	 */
	@Test
	public void testRemoveAllFriends() {
		
		user.removeAllFriends();
		
		assertEquals(user.getFriends().size(),0);
	}
}
